import { projects } from "@/assets/js/config/index.js";
import storage from "./storage";

export const siteDomain = getSiteInfo().siteDomain;
export function getSiteInfo() {
  let siteInfo = storage.get("siteInfo");

  return siteInfo;
}
export function getIsOpen(siteInfo) {
  let isUpgrade = false;
  if (siteInfo.state == 0) {
    isUpgrade = true;
  } else if (
    new Date(siteInfo.upgradeStartTime).getTime() < new Date() &&
    new Date(siteInfo.upgradeEndTime).getTime() > new Date()
  ) {
    isUpgrade = true;
  }
  return isUpgrade;
}
export function replaceProjectInfo({ ele }) {
  let siteInfo = getSiteInfo("siteInfo");
  // let {id} = siteInfo;
  //   if(id == 2) { // ai2030
  //     return;
  //   }
  //   if (ele) {

  const beforeContent = ele.value.innerHTML;
  // const reg = new RegExp()
  // channelName对应公司名，siteName对应简称
  let newContent = beforeContent.replace(
    /myChannelName/gi,
    siteInfo.channelName
  );
  newContent = newContent.replace(/mySiteName/gi, siteInfo.siteName);
  ele.value.innerHTML = newContent;
  // }
}
